package com.xunji.xunji.ui;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.huanxiao.base.base.BaseActivity;
import com.xunji.xunji.R;

/**
 * Created by paul on 16/10/19.
 */

public class WebViewActivity extends BaseActivity {

    private static final String EXTRA_TITLE = "title";
    private static final String EXTRA_URL = "url";
    private static final String EXTRA_SHOW_NAVI = "is_show_navi";


    protected String mUrl;
    protected String mTitle;
    protected boolean mIsShowNavigation = true;

    public static void start(Context context, String title, String url) {
        Intent starter = new Intent(context, WebViewActivity.class);
        starter.putExtra(EXTRA_TITLE, title);
        starter.putExtra(EXTRA_URL, url);
        context.startActivity(starter);
    }

    public static void start(Context context, String title, String url, boolean isShowNavi) {
        Intent starter = new Intent(context, WebViewActivity.class);
        starter.putExtra(EXTRA_TITLE, title);
        starter.putExtra(EXTRA_URL, url);
        starter.putExtra(EXTRA_SHOW_NAVI, isShowNavi);
        context.startActivity(starter);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_webview;
    }

    @Override
    protected void initPresenter() {

    }

    @Override
    public void initBundleExtras(Bundle extras) {
        mUrl = extras.getString(EXTRA_URL);
        mTitle = extras.getString(EXTRA_TITLE);
        if (extras.containsKey(EXTRA_SHOW_NAVI)) {
            mIsShowNavigation = extras.getBoolean(EXTRA_SHOW_NAVI);
        }
    }

    @Override
    protected void initView() {
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        Fragment fragment = WebViewFragment.newInstance(mTitle, mUrl, mIsShowNavigation);
        getSupportFragmentManager().beginTransaction().replace(R.id.frame_content, fragment).commit();
    }

    @Override
    protected boolean isBindEventBus() {
        return false;
    }
}
